package com.picket.domain;

import java.util.Date;
import java.util.UUID;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class Pool {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

	@NotNull
	@Size(min=1, max=50)
	@Persistent
	private String name;
	
	@NotNull
	@Persistent
	private long eventId;
	
	@Persistent 
	private String referralKey;
	
	@Persistent 
	private String owner;
	
	@Persistent
	private String type;
	
	@Persistent
    private Date createDate;
	
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Key getKey() {
		return key;
	}

	public long getId() {
	    return key.getId();
	}
	 
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getEventId() {
		return eventId;
	}

	public void setEventId(long eventId) {
		this.eventId = eventId;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getReferralKey() {
		return referralKey;
	}
	
	public void generateReferralKey(){
		String uniqueId = UUID.randomUUID().toString();//fromString(event.getId()+name+(createDate.getTime()))).toString();
		referralKey = uniqueId;
	}

}